<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" href="jquery/css/sexybuttons.css" type="text/css" />
        <script type="text/javascript" src="jquery/js/jquery-1.3.2.min.js"></script>
        <script type="text/javascript">

            $(document).ready(
                function(){
                    $("#sudokuerName").change(hasSameName);
                }
               );
        
            function hasSameName() {
                if($("#sudokuerName").val()=="")
                    return;
                var url = "register/hasSameNameAction";
                var param = {sudokuerName:$("#sudokuerName").val()};
                $.getJSON(
                    url,
                    param,
                    function(data){
                        var flag = eval("("+data+")");
                        if(flag.count=="0") {
                        	$("td:eq(2)").empty().append("<font color=\"green\">用户名可用</font>");
                        	$("#submit").attr("disabled","");
                        }else {
                            $("td:eq(2)").empty().append("<font color=\"red\">用户名已被使用</font>");
                            $("#submit").attr("disabled","disabled");
                        }
                    }
                );
            }
        </script>
        
        <style type="text/css">
            #formdiv {
                width:500px;
                margin-top: 10px;
                margin-left: auto;
                margin-right: auto;
                text-align: center;
            }
        
            #formdiv form {
                background-color: #fff;
                padding: 2px;
                border: 1px solid #ccc;
                margin: 2px 5px;
                -moz-border-radius: 4px;
                -webkit-border-radius: 4px;
            }
        </style>
        
        <title>Insert title here</title>
    </head>
    <body>
        <div align="center" id="formdiv">
            <form id="register" action="register/registerAction" method="post">
                <table>
                    <tr>
                        <td align="right" style="width:80px">名称:</td>
                        <td>
                            <input id="sudokuerName" name="sudokuerName" type="text"/>
                        </td>
                        <td></td>
                    </tr>
                    <tr>
                        <td align="right" style="width:80px">密码:</td>
                        <td>
                            <input id="password" name="password" type="password"/>
                        </td>
                        <td></td>
                    </tr>
                    <tr>
                        <td align="right" style="width:80px">国家:</td>
                        <td>
                            <input id="nation" name="nation" type="text"/>
                        </td>
                        <td></td>
                    </tr>
                    <tr>
                        <td align="right" style="width:80px">年龄:</td>
                        <td>
                            <input id="age" name="age" type="text"/>
                        </td>
                        <td></td>
                    </tr>
                    <tr>
                        <td align="right" style="width:80px">游戏年龄:</td>
                        <td>
                            <input id="sudokuAge" name="sudokuAge" type="text"/>
                        </td>
                        <td></td>
                    </tr>
                    <tr>
                        <td colspan="2" align="right">
                            <button id="submit" type="submit" class="sexybutton sexysimple sexymedium" disabled="disabled">提  交</button>
                        </td>
                    </tr>
                </table>
            </form>
        </div>
    </body>
</html>